


use ppi
/*
-- // checksum failed custom error
exec sp_addmessage @msgnum = 505050, @severity = 16, @msgtext = N'%s(%s) checksum compare failed', @replace = 'REPLACE', @lang = 'us_english'
GO

-- // not found custom error
exec sp_addmessage @msgnum = 505060, @severity = 16, @msgtext = N'%s(%s) does not exist', @replace = 'REPLACE', @lang = 'us_english'
GO

-- // unit test custom error
exec sp_addmessage @msgnum = 505070, @severity = 16, @msgtext = N'%s Test Failed. Expected< %s > Actual< %s > %s', @replace = 'REPLACE', @lang = 'us_english'
GO

*/

use ppi

if exists (select * from dbo.sysobjects where id = object_id(N'v_tb_Vendor_Distribution_Sectionalizers') and OBJECTPROPERTY(id, N'IsProcedure') = 0)
drop view v_tb_Vendor_Distribution_Sectionalizers
GO

create view v_tb_Vendor_Distribution_Sectionalizers as
	/* 	Initial Generated Date:  viernes, 03 de septiembre de 2010 
		Purpose: Selected record(s) from the table; this view is the source for all procedures' select statements
	*/
	
select
	 [Vendor_Distribution_Sectionalizers_SectionalizerId] as [Vendor_Distribution_Sectionalizers_SectionalizerId]
	,[Vendor_Distribution_PoleFk] as [Vendor_Distribution_PoleFk]
	,[Utility_Asset_Sectionalizers_SectionalizerFk] as [Utility_Asset_Sectionalizers_SectionalizerFk]
	,[Latitude] as [Latitude]
	,[Longitude] as [Longitude]
	,[CreatedDate] as [CreatedDate]
	,[Manufacturer] as [Manufacturer]
	,[SerialNumber] as [SerialNumber]
	,[ManufDate] as [ManufDate]
	,[PoleNumber] as [PoleNumber]
	,[PhaseFk] as [PhaseFk]
	,[MaxkV] as [MaxkV]
	,[Type] as [Type]
	,[CurveA] as [CurveA]
	,[CurveB] as [CurveB]
	,[CurveC] as [CurveC]
	,[CurveD] as [CurveD]
	,[Interrupter] as [Interrupter]
	,[Pre1978] as [Pre1978]
	,[PCBType] as [PCBType]
	,[PPM] as [PPM]
	,[DeterminedByFk] as [DeterminedByFk]
	,[TestNo] as [TestNo]
	,[Sticker] as [Sticker]
	,[Comments] as [Comments]
	-- customization may be required for FriendlyName
	,Left(CONVERT(varchar(255), [Vendor_Distribution_Sectionalizers_SectionalizerId]), 255) as [FriendlyName]
from
	tb_Vendor_Distribution_Sectionalizers
GO





use ppi

if exists (select * from dbo.sysobjects where id = object_id(N'up_VendorDistributionSectionalizer_Test') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure up_VendorDistributionSectionalizer_Test
GO


create proc up_VendorDistributionSectionalizer_Test
	@Vendor_Distribution_Sectionalizers_SectionalizerId int
as
	/* 	Initial Generated Date:  viernes, 03 de septiembre de 2010 
		Purpose: Test if a record exists, using the primary key
	*/

SET NOCOUNT ON	
	
if exists(
	select [Vendor_Distribution_Sectionalizers_SectionalizerId] 
	from [tb_Vendor_Distribution_Sectionalizers] source
	where [source].[Vendor_Distribution_Sectionalizers_SectionalizerId] = @Vendor_Distribution_Sectionalizers_SectionalizerId)
begin
	return(1)
end
else
begin
	return(0)
end
GO






use ppi

if exists (select * from dbo.sysobjects where id = object_id(N'up_VendorDistributionSectionalizer_Select') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure up_VendorDistributionSectionalizer_Select
GO

create proc up_VendorDistributionSectionalizer_Select
	 @Vendor_Distribution_Sectionalizers_SectionalizerId int = null 
	,@Vendor_Distribution_PoleFk int = null 
	,@Utility_Asset_Sectionalizers_SectionalizerFk int = null 
	,@Latitude float = null 
	,@Longitude float = null 
	,@CreatedDate datetime = null 
	,@Manufacturer nvarchar(100) = null 
	,@SerialNumber nvarchar(100) = null 
	,@ManufDate datetime = null 
	,@PoleNumber nvarchar(100) = null 
	,@PhaseFk int = null 
	,@MaxkV nvarchar(100) = null 
	,@Type nvarchar(100) = null 
	,@CurveA int = null 
	,@CurveB int = null 
	,@CurveC int = null 
	,@CurveD int = null 
	,@Interrupter int = null 
	,@Pre1978 bit = null 
	,@PCBType int = null 
	,@PPM nvarchar(100) = null 
	,@DeterminedByFk int = null 
	,@TestNo nvarchar(100) = null 
	,@Sticker bit = null 
	,@Comments nvarchar(max) = null 
as
	/* 	Initial Generated Date:  viernes, 03 de septiembre de 2010 
		Purpose: Selected record(s) based on the passed arguments; no arguments returns all
	*/

SET NOCOUNT ON	

select * from v_tb_Vendor_Distribution_Sectionalizers
where
		IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Vendor_Distribution_Sectionalizers_SectionalizerId], -1) = Coalesce(@Vendor_Distribution_Sectionalizers_SectionalizerId, [v_tb_Vendor_Distribution_Sectionalizers].[Vendor_Distribution_Sectionalizers_SectionalizerId], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Vendor_Distribution_PoleFk], -1) = Coalesce(@Vendor_Distribution_PoleFk, [v_tb_Vendor_Distribution_Sectionalizers].[Vendor_Distribution_PoleFk], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Utility_Asset_Sectionalizers_SectionalizerFk], -1) = Coalesce(@Utility_Asset_Sectionalizers_SectionalizerFk, [v_tb_Vendor_Distribution_Sectionalizers].[Utility_Asset_Sectionalizers_SectionalizerFk], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Latitude], -1) = Coalesce(@Latitude, [v_tb_Vendor_Distribution_Sectionalizers].[Latitude], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Longitude], -1) = Coalesce(@Longitude, [v_tb_Vendor_Distribution_Sectionalizers].[Longitude], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[CreatedDate], '1/1/1900 12:00AM') = Coalesce(@CreatedDate, [v_tb_Vendor_Distribution_Sectionalizers].[CreatedDate], '1/1/1900 12:00AM')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Manufacturer], '') = Coalesce(@Manufacturer, [v_tb_Vendor_Distribution_Sectionalizers].[Manufacturer], '')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[SerialNumber], '') = Coalesce(@SerialNumber, [v_tb_Vendor_Distribution_Sectionalizers].[SerialNumber], '')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[ManufDate], '1/1/1900 12:00AM') = Coalesce(@ManufDate, [v_tb_Vendor_Distribution_Sectionalizers].[ManufDate], '1/1/1900 12:00AM')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[PoleNumber], '') = Coalesce(@PoleNumber, [v_tb_Vendor_Distribution_Sectionalizers].[PoleNumber], '')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[PhaseFk], -1) = Coalesce(@PhaseFk, [v_tb_Vendor_Distribution_Sectionalizers].[PhaseFk], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[MaxkV], '') = Coalesce(@MaxkV, [v_tb_Vendor_Distribution_Sectionalizers].[MaxkV], '')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Type], '') = Coalesce(@Type, [v_tb_Vendor_Distribution_Sectionalizers].[Type], '')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[CurveA], -1) = Coalesce(@CurveA, [v_tb_Vendor_Distribution_Sectionalizers].[CurveA], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[CurveB], -1) = Coalesce(@CurveB, [v_tb_Vendor_Distribution_Sectionalizers].[CurveB], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[CurveC], -1) = Coalesce(@CurveC, [v_tb_Vendor_Distribution_Sectionalizers].[CurveC], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[CurveD], -1) = Coalesce(@CurveD, [v_tb_Vendor_Distribution_Sectionalizers].[CurveD], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Interrupter], -1) = Coalesce(@Interrupter, [v_tb_Vendor_Distribution_Sectionalizers].[Interrupter], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Pre1978], 0) = Coalesce(@Pre1978, [v_tb_Vendor_Distribution_Sectionalizers].[Pre1978], 0)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[PCBType], -1) = Coalesce(@PCBType, [v_tb_Vendor_Distribution_Sectionalizers].[PCBType], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[PPM], '') = Coalesce(@PPM, [v_tb_Vendor_Distribution_Sectionalizers].[PPM], '')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[DeterminedByFk], -1) = Coalesce(@DeterminedByFk, [v_tb_Vendor_Distribution_Sectionalizers].[DeterminedByFk], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[TestNo], '') = Coalesce(@TestNo, [v_tb_Vendor_Distribution_Sectionalizers].[TestNo], '')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Sticker], 0) = Coalesce(@Sticker, [v_tb_Vendor_Distribution_Sectionalizers].[Sticker], 0)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Comments], '') = Coalesce(@Comments, [v_tb_Vendor_Distribution_Sectionalizers].[Comments], '')
GO





use ppi

if exists (select * from dbo.sysobjects where id = object_id(N'up_VendorDistributionSectionalizer_Select_Top1') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure up_VendorDistributionSectionalizer_Select_Top1
GO

create proc up_VendorDistributionSectionalizer_Select_Top1
	 @Vendor_Distribution_Sectionalizers_SectionalizerId int = null 
	,@Vendor_Distribution_PoleFk int = null 
	,@Utility_Asset_Sectionalizers_SectionalizerFk int = null 
	,@Latitude float = null 
	,@Longitude float = null 
	,@CreatedDate datetime = null 
	,@Manufacturer nvarchar(100) = null 
	,@SerialNumber nvarchar(100) = null 
	,@ManufDate datetime = null 
	,@PoleNumber nvarchar(100) = null 
	,@PhaseFk int = null 
	,@MaxkV nvarchar(100) = null 
	,@Type nvarchar(100) = null 
	,@CurveA int = null 
	,@CurveB int = null 
	,@CurveC int = null 
	,@CurveD int = null 
	,@Interrupter int = null 
	,@Pre1978 bit = null 
	,@PCBType int = null 
	,@PPM nvarchar(100) = null 
	,@DeterminedByFk int = null 
	,@TestNo nvarchar(100) = null 
	,@Sticker bit = null 
	,@Comments nvarchar(max) = null 
as
	/* 	Initial Generated Date:  viernes, 03 de septiembre de 2010 
		Purpose: Selected top 1 record based on the passed arguments; no arguments returns all
	*/

SET NOCOUNT ON	

select TOP 1 * from v_tb_Vendor_Distribution_Sectionalizers
where
		IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Vendor_Distribution_Sectionalizers_SectionalizerId], -1) = Coalesce(@Vendor_Distribution_Sectionalizers_SectionalizerId, [v_tb_Vendor_Distribution_Sectionalizers].[Vendor_Distribution_Sectionalizers_SectionalizerId], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Vendor_Distribution_PoleFk], -1) = Coalesce(@Vendor_Distribution_PoleFk, [v_tb_Vendor_Distribution_Sectionalizers].[Vendor_Distribution_PoleFk], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Utility_Asset_Sectionalizers_SectionalizerFk], -1) = Coalesce(@Utility_Asset_Sectionalizers_SectionalizerFk, [v_tb_Vendor_Distribution_Sectionalizers].[Utility_Asset_Sectionalizers_SectionalizerFk], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Latitude], -1) = Coalesce(@Latitude, [v_tb_Vendor_Distribution_Sectionalizers].[Latitude], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Longitude], -1) = Coalesce(@Longitude, [v_tb_Vendor_Distribution_Sectionalizers].[Longitude], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[CreatedDate], '1/1/1900 12:00AM') = Coalesce(@CreatedDate, [v_tb_Vendor_Distribution_Sectionalizers].[CreatedDate], '1/1/1900 12:00AM')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Manufacturer], '') = Coalesce(@Manufacturer, [v_tb_Vendor_Distribution_Sectionalizers].[Manufacturer], '')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[SerialNumber], '') = Coalesce(@SerialNumber, [v_tb_Vendor_Distribution_Sectionalizers].[SerialNumber], '')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[ManufDate], '1/1/1900 12:00AM') = Coalesce(@ManufDate, [v_tb_Vendor_Distribution_Sectionalizers].[ManufDate], '1/1/1900 12:00AM')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[PoleNumber], '') = Coalesce(@PoleNumber, [v_tb_Vendor_Distribution_Sectionalizers].[PoleNumber], '')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[PhaseFk], -1) = Coalesce(@PhaseFk, [v_tb_Vendor_Distribution_Sectionalizers].[PhaseFk], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[MaxkV], '') = Coalesce(@MaxkV, [v_tb_Vendor_Distribution_Sectionalizers].[MaxkV], '')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Type], '') = Coalesce(@Type, [v_tb_Vendor_Distribution_Sectionalizers].[Type], '')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[CurveA], -1) = Coalesce(@CurveA, [v_tb_Vendor_Distribution_Sectionalizers].[CurveA], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[CurveB], -1) = Coalesce(@CurveB, [v_tb_Vendor_Distribution_Sectionalizers].[CurveB], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[CurveC], -1) = Coalesce(@CurveC, [v_tb_Vendor_Distribution_Sectionalizers].[CurveC], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[CurveD], -1) = Coalesce(@CurveD, [v_tb_Vendor_Distribution_Sectionalizers].[CurveD], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Interrupter], -1) = Coalesce(@Interrupter, [v_tb_Vendor_Distribution_Sectionalizers].[Interrupter], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Pre1978], 0) = Coalesce(@Pre1978, [v_tb_Vendor_Distribution_Sectionalizers].[Pre1978], 0)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[PCBType], -1) = Coalesce(@PCBType, [v_tb_Vendor_Distribution_Sectionalizers].[PCBType], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[PPM], '') = Coalesce(@PPM, [v_tb_Vendor_Distribution_Sectionalizers].[PPM], '')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[DeterminedByFk], -1) = Coalesce(@DeterminedByFk, [v_tb_Vendor_Distribution_Sectionalizers].[DeterminedByFk], -1)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[TestNo], '') = Coalesce(@TestNo, [v_tb_Vendor_Distribution_Sectionalizers].[TestNo], '')
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Sticker], 0) = Coalesce(@Sticker, [v_tb_Vendor_Distribution_Sectionalizers].[Sticker], 0)
	AND	IsNull([v_tb_Vendor_Distribution_Sectionalizers].[Comments], '') = Coalesce(@Comments, [v_tb_Vendor_Distribution_Sectionalizers].[Comments], '')
GO




use ppi

if exists (select * from dbo.sysobjects where id = object_id(N'up_VendorDistributionSectionalizer_Insert') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure up_VendorDistributionSectionalizer_Insert
GO

create proc up_VendorDistributionSectionalizer_Insert
	 @Vendor_Distribution_Sectionalizers_SectionalizerId int =null OUTPUT  
	,@Vendor_Distribution_PoleFk int  
	,@Utility_Asset_Sectionalizers_SectionalizerFk int = null  
	,@Latitude float = null  
	,@Longitude float = null  
	,@CreatedDate datetime = null  
	,@Manufacturer nvarchar(100) = null  
	,@SerialNumber nvarchar(100) = null  
	,@ManufDate datetime = null  
	,@PoleNumber nvarchar(100) = null  
	,@PhaseFk int = null  
	,@MaxkV nvarchar(100) = null  
	,@Type nvarchar(100) = null  
	,@CurveA int = null  
	,@CurveB int = null  
	,@CurveC int = null  
	,@CurveD int = null  
	,@Interrupter int = null  
	,@Pre1978 bit = null  
	,@PCBType int = null  
	,@PPM nvarchar(100) = null  
	,@DeterminedByFk int = null  
	,@TestNo nvarchar(100) = null  
	,@Sticker bit = null  
	,@Comments nvarchar(max) = null  
as
	/* 	Initial Generated Date:  viernes, 03 de septiembre de 2010 
		Purpose: Inserts a new record; missing arguments are set as their default (typically null)
	*/

SET NOCOUNT ON	
--int

insert tb_Vendor_Distribution_Sectionalizers 
	(
	
	 [Vendor_Distribution_PoleFk] 
	,[Utility_Asset_Sectionalizers_SectionalizerFk] 
	,[Latitude] 
	,[Longitude] 
	,[CreatedDate] 
	,[Manufacturer] 
	,[SerialNumber] 
	,[ManufDate] 
	,[PoleNumber] 
	,[PhaseFk] 
	,[MaxkV] 
	,[Type] 
	,[CurveA] 
	,[CurveB] 
	,[CurveC] 
	,[CurveD] 
	,[Interrupter] 
	,[Pre1978] 
	,[PCBType] 
	,[PPM] 
	,[DeterminedByFk] 
	,[TestNo] 
	,[Sticker] 
	,[Comments] 
	)
	values
	(
	
	 @Vendor_Distribution_PoleFk 
	,@Utility_Asset_Sectionalizers_SectionalizerFk 
	,@Latitude 
	,@Longitude 
	,@CreatedDate 
	,@Manufacturer 
	,@SerialNumber 
	,@ManufDate 
	,@PoleNumber 
	,@PhaseFk 
	,@MaxkV 
	,@Type 
	,@CurveA 
	,@CurveB 
	,@CurveC 
	,@CurveD 
	,@Interrupter 
	,@Pre1978 
	,@PCBType 
	,@PPM 
	,@DeterminedByFk 
	,@TestNo 
	,@Sticker 
	,@Comments 
	)
set @Vendor_Distribution_Sectionalizers_SectionalizerId = scope_identity()
select * from v_tb_Vendor_Distribution_Sectionalizers where Vendor_Distribution_Sectionalizers_SectionalizerId = @Vendor_Distribution_Sectionalizers_SectionalizerId

GO




use ppi

if exists (select * from dbo.sysobjects where id = object_id(N'up_VendorDistributionSectionalizer_Update') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure up_VendorDistributionSectionalizer_Update
GO


create proc up_VendorDistributionSectionalizer_Update
	 @Vendor_Distribution_Sectionalizers_SectionalizerId int  
	,@Vendor_Distribution_PoleFk int = null  
	,@Utility_Asset_Sectionalizers_SectionalizerFk int = null  
	,@Latitude float = null  
	,@Longitude float = null  
	,@CreatedDate datetime = null  
	,@Manufacturer nvarchar(100) = null  
	,@SerialNumber nvarchar(100) = null  
	,@ManufDate datetime = null  
	,@PoleNumber nvarchar(100) = null  
	,@PhaseFk int = null  
	,@MaxkV nvarchar(100) = null  
	,@Type nvarchar(100) = null  
	,@CurveA int = null  
	,@CurveB int = null  
	,@CurveC int = null  
	,@CurveD int = null  
	,@Interrupter int = null  
	,@Pre1978 bit = null  
	,@PCBType int = null  
	,@PPM nvarchar(100) = null  
	,@DeterminedByFk int = null  
	,@TestNo nvarchar(100) = null  
	,@Sticker bit = null  
	,@Comments nvarchar(max) = null  
	,@OriginalVendor_Distribution_Sectionalizers_SectionalizerId int  = null --Original PrimaryKey
	
as
	/* 	Initial Generated Date:  viernes, 03 de septiembre de 2010 
		Purpose: Updates an existing record, verifying exist; missing arguments persist original record value
		NOTE: this version of the update allows up to write nulls to the table.
	*/

SET NOCOUNT ON	

if @OriginalVendor_Distribution_Sectionalizers_SectionalizerId is null
	set @OriginalVendor_Distribution_Sectionalizers_SectionalizerId = @Vendor_Distribution_Sectionalizers_SectionalizerId

-- test
declare @Result bit
execute @Result = up_VendorDistributionSectionalizer_Test @OriginalVendor_Distribution_Sectionalizers_SectionalizerId
if (not @Result = 1)
begin
	Declare @x varchar(100)
	Set @x = Convert(Varchar(100), @Vendor_Distribution_Sectionalizers_SectionalizerId)
	raiserror(505060, 16, 1, 'VendorDistributionSectionalizer', @x)
	return
end

-- proceed
update tb_Vendor_Distribution_Sectionalizers 
set

	 [Vendor_Distribution_PoleFk] = IsNull(@Vendor_Distribution_PoleFk, [source].[Vendor_Distribution_PoleFk])
	,[Utility_Asset_Sectionalizers_SectionalizerFk] =  @Utility_Asset_Sectionalizers_SectionalizerFk
	,[Latitude] =  @Latitude
	,[Longitude] =  @Longitude
	,[CreatedDate] =  @CreatedDate
	,[Manufacturer] =  @Manufacturer
	,[SerialNumber] =  @SerialNumber
	,[ManufDate] =  @ManufDate
	,[PoleNumber] =  @PoleNumber
	,[PhaseFk] =  @PhaseFk
	,[MaxkV] =  @MaxkV
	,[Type] =  @Type
	,[CurveA] =  @CurveA
	,[CurveB] =  @CurveB
	,[CurveC] =  @CurveC
	,[CurveD] =  @CurveD
	,[Interrupter] =  @Interrupter
	,[Pre1978] =  @Pre1978
	,[PCBType] =  @PCBType
	,[PPM] =  @PPM
	,[DeterminedByFk] =  @DeterminedByFk
	,[TestNo] =  @TestNo
	,[Sticker] =  @Sticker
	,[Comments] =  @Comments
	
from tb_Vendor_Distribution_Sectionalizers source
where
	[source].[Vendor_Distribution_Sectionalizers_SectionalizerId] = @OriginalVendor_Distribution_Sectionalizers_SectionalizerId


select * from v_tb_Vendor_Distribution_Sectionalizers where Vendor_Distribution_Sectionalizers_SectionalizerId = @Vendor_Distribution_Sectionalizers_SectionalizerId
GO





use ppi

if exists (select * from dbo.sysobjects where id = object_id(N'up_VendorDistributionSectionalizer_Delete') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure up_VendorDistributionSectionalizer_Delete
GO


create proc up_VendorDistributionSectionalizer_Delete
	@Vendor_Distribution_Sectionalizers_SectionalizerId int
as
	/* 	Initial Generated Date:  viernes, 03 de septiembre de 2010 
		Purpose: Deletes an existing record, verifying exist
	*/

SET NOCOUNT ON	

-- test
declare @Result bit
execute @Result = up_VendorDistributionSectionalizer_Test @Vendor_Distribution_Sectionalizers_SectionalizerId
if (not @Result = 1)
begin
	Declare @x varchar(100)
	Set @x = Convert(Varchar(100), @Vendor_Distribution_Sectionalizers_SectionalizerId)
	raiserror(505060, 16, 1, 'VendorDistributionSectionalizer', @x)
	return
end

-- proceed
delete from tb_Vendor_Distribution_Sectionalizers 
where [Vendor_Distribution_Sectionalizers_SectionalizerId] = @Vendor_Distribution_Sectionalizers_SectionalizerId

GO


